<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Client extends User_Controller
{
private $response = array();
	private $userModel;
	private $clientModel;
	private $requestManager;
	private $settings;
    public function __construct()
    {
        parent::__construct();
        
    	if(isset($this->session) && !$this->session->userdata('isLogged')) {
        	redirect('/');
        }
        
        $this->userModel = $this->load->model('User_Model');
        $this->clientModel = $this->load->model('Client_Model');
        $this->load->helper('RequestManager');
        $this->requestManager = RequestManager::getInstance();
        $this->settings = $this->config->item('settings');
        $this->load->helper(array('ConstantsUtils','StringUtils','DateUtils'));
    
        
    }

    public function index()
    {
        // send API call
        $this->requestManager->setSendType("rest");
        $this->requestManager->setAccessPath(Settings::config('api_path').'client/get_client_list/' .Settings::config('client_key').'/'.$this->session->userdata('client_id'));
        $response = $this->requestManager->send();
        
        $data['clients'] = array();
        
        if ($response->message == 'success') {
            $data['clients'] = $response->data;
        }
        
    	$this->load->view('header');
		$this->load->view('index',$data);
		$this->load->view('footer');
    }
    
	
}